﻿
using AduSkin.Controls.Data;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Helper.Model;
using Helper.View;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;

namespace Helper.ViewModel
{
    public class StudyTaskbarViewModel : ViewModelBase
    {
        public List<TaskModel> TotalContactList;

        private ObservableCollection<TaskModel> contactList;
        /// <summary>
        /// 联系人列表
        /// </summary>
        public ObservableCollection<TaskModel> ContactList
        {
            get { return contactList; }
            set { Set(ref contactList, value); }
        }

        public StudyTaskbarViewModel()
        {
            TotalContactList = new List<TaskModel>();
            TaskModel a =new TaskModel(0);
            TaskModel b =new TaskModel(1);
            TaskModel c =new TaskModel(2);
            TaskModel d =new TaskModel(3);
            TotalContactList.Add(a);
            TotalContactList.Add(b);
            TotalContactList.Add(c);
            TotalContactList.Add(d);

            ContactList = new ObservableCollection<TaskModel>(TotalContactList.Skip((1 - 1) * 10).Take(10).ToList());




            DispatcherTimer timer = new DispatcherTimer();
            timer.Tick += delegate
            {
                if (IsStartTask())
                {
                    ContactList = new ObservableCollection<TaskModel>(TotalContactList.Skip((1 - 1) * 10).Take(10).ToList());
                    Debug.WriteLine("刷新");
                }
            };
            timer.Interval = new TimeSpan(0, 0, 0,1,0);
            timer.Start();
        }

        private bool IsStartTask()
        {
            foreach (var item in TotalContactList)
            {

                if (item.IsChecked) return true;
            }
            return false;
        }
     
    }
   
   
}
